
import sys
sys.path.append(r'\\192.168.131.222\kali\Lib\site-packages\32')
import os
import time
import MySQLdb
import socket
import pickle
import shutil

cmd = "execfile(r'\\\\192.168.131.222\\kali\\Lib\\startUp\\autoexec.py')"
userAuto = r"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\userAutoexec.py"
RNDlist=[ 'onetera' , 'SUJIN' , 'ikkun' , 'cgh' ]
TDlist=['Character_TD','chartdA','chartdB', 'alien' ] + RNDlist


os.system(r"net use x: \\192.168.131.222\3DFC")
os.system(r"net use y: \\192.168.131.222\kali")
os.system(r"net use z: \\192.168.131.222\projects")

if os.path.isfile(userAuto):
    os.remove(userAuto) 
f = file(userAuto,'w')
f.write(cmd)
f.close()

os.environ['IP_ADDRESS'] = socket.gethostbyname(socket.gethostname())
#os.environ['dataServer'] = r'\\'+SERVER_IP
os.environ['userINIpath'] = '\\\\192.168.131.222\\kali\\INI\\'+os.environ['USERNAME']

if not os.path.isdir(os.environ['userINIpath']) :
    os.mkdir(os.environ['userINIpath'])
    
USERfolder = "C:\\Users\\"+ os.environ['USERNAME']    
if os.path.isdir(USERfolder):
    MAYAuserSetup = USERfolder +"\\Documents\\maya\\scripts\\userSetup.py"
else :
    USERfolder = "C:\\Users\\"+ os.environ['COMPUTERNAME']
    MAYAuserSetup = USERfolder +"\\Documents\\maya\\scripts\\userSetup.py"
    
# Create shelf and tools
mayaVer = ['2011','2011-x64','2012','2012-x64']
for ver in mayaVer:
    if os.path.isdir(USERfolder+'\\Documents\\maya\\'+ver+'\\prefs\\shelves'):
        shutil.copy(r"y:\UI\prefs\shelves\shelf_SOA.mel",
                        USERfolder+'\\Documents\\maya\\'+ver+'\\prefs\\shelves')        

if os.environ['USERNAME'] in TDlist:
    for ver in mayaVer:
        if os.path.isdir(USERfolder+'\\Documents\\maya\\'+ver+'\\prefs\\shelves'):
            shutil.copy(r"Y:\UI\prefs\shelves\shelf_setUp.mel",
                        USERfolder+'\\Documents\\maya\\'+ver+'\\prefs\\shelves')        
    
if os.path.isfile(MAYAuserSetup):
    os.remove(MAYAuserSetup)
f = file(MAYAuserSetup,'w')
f.write('execfile(r"\\\\192.168.131.222\\kali\\Lib\\startUp\\userSetup.py")')
f.close()


